<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>闭包</title>
		<script type="text/javascript">
			
			function test(){
				var arr = [];
				for (var i = 0; i < 10; i++) {
					arr[i] = function(){
						document.write(i + " ");
					}
				}
				return arr;
			}
			
			var demo = test();
			for (var j = 0; j < 10; j++) {
				demo[j]();
			}
		</script>
	</head>
	<body>
	</body>
</html>
